package com.wanghua.mall.order.webcontroller;

import com.wanghua.mall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author wanghua
 * @create 2021-09-07 21:26
 */
@Controller
public class TestController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/test")
    public String test() {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setId(12306L);
        orderEntity.setGmtCreate(new Date());
        rabbitTemplate.convertAndSend("order-event-exchange", "order-create-order",
                orderEntity);
        System.out.println(orderEntity);
        return "ok";
    }
}
